


// int gpio_irq = MXS_PIN_TO_GPIO(MXS_PIN_ENCODE(0, 18));

// int gpio_irq = MXS_PIN_TO_GPIO(MXS_PIN_ENCODE(0, 18));
#define CONFIG_SPI 
// #include <ls2k.h>
#include <linux/module.h>
#include "linux/spi/spi.h"
#include <linux/platform_device.h>
#include "linux/platform_device.h"
#include <linux/err.h>

#define LS2K_IO_REG_BASE		0x1f000000
#define LS2K_SPI_REG_BASE		(LS2K_IO_REG_BASE + 0xff0220)

static struct spi_board_info spi_board_info[2] __initdata = {
	{
		/* the modalias must be the same as spi device driver name */
		.modalias = "spidev", /* Name of spi_driver for this device */
		.max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
		.bus_num = 0, /* Framework bus number */
		.chip_select = 0, /* Framework chip select.0:ssn0 1 ssn1 2 ssn2 */
	},
	{
		/* the modalias must be the same as spi device driver name */
		.modalias = "spidev", /* Name of spi_driver for this device */
		.max_speed_hz = 24000000,     /* max spi clock (SCK) speed in HZ */
		.bus_num = 0, /* Framework bus number */
		.chip_select = 1, /* Framework chip select.0:ssn0 1 ssn1 2 ssn2 */
	},
};


static struct resource ls2k_spi0_resources[]={
	[0]={
		.start      =   LS2K_SPI_REG_BASE,
		.end        =   LS2K_SPI_REG_BASE+6,
		.flags      =   IORESOURCE_MEM,
	},  
};

static struct platform_device ls2k_spi0_device={
	.name   =   "ls2k-spi",
	.id     =       0,
	.num_resources  =ARRAY_SIZE(ls2k_spi0_resources),
	.resource       =ls2k_spi0_resources,
};



static struct platform_device *ls2k_platform_devices[] = {
    &ls2k_spi0_device,
};
static void spi_device_init(void)
{
	spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
}

int __init ls2k_devices_init(void)
{
    // platform_add_devices(the_devices, ARRAY_SIZE(the_devices));
    
    platform_add_devices(ls2k_platform_devices,
			ARRAY_SIZE(ls2k_platform_devices));
    spi_device_init();
    printk("insmod module\r\n");
    return 0;
}

void __exit ls2k_devices_exit(void)
{
    // platform_device_unregister(&tk100_red);
    // platform_device_unregister(&mxs_leds_gpio_device);
    printk("remove module\r\n");
}

module_init(ls2k_devices_init);
module_exit(ls2k_devices_exit);

MODULE_LICENSE("GPL");

// MODULE_DESCRIPTION("glink devices user space export");
